package com.itheima.boot.mapper;

import com.itheima.boot.domain.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {

    @ResultMap("bookResultMap")
    @Insert("insert into tbl_book (book_name,description,price,stock,status) values(#{bookName},#{description},#{price},#{stock},#{status})")
    public int save(Book book);

    @ResultMap("bookResultMap")
    @Update("update tbl_book set book_name = #{bookName}, description = #{description} , price=#{price},stock= #{stock}, status= #{status} where id = #{id}")
    public int update(Book book);

    @Delete("delete from tbl_book where id = #{id}")
    public int delete(Integer id);

    @Select("select * from tbl_book where id = #{id}")
    public Book getById(Integer id);

//    @Select("select * from tbl_book")
    public List<Book> getAll(@Param("bookName") String bookName,@Param("status") Integer status);

//    public List<Book>  selectByCondition( @Param("bookName") String bookName,@Param("status") Integer status);

}